package com.oa.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.oa.base.BaseDaoImpl;
import com.oa.dao.DepartmentDao;
import com.oa.entity.Department;
@SuppressWarnings("unchecked")
@Repository("departmentDao")
public class DepartmentDaoImpl extends BaseDaoImpl<Department> implements DepartmentDao {
	// 查询第一个部门列表
	public List<Department> findTopList() {
		return getSession().createQuery(
				"FROM Department d WHERE d.department_parent IS NULL")
				.list();
	}
	// 查询子部们列表
	public List<Department> findChildren(String parentId) {
		return getSession().createQuery(
				"FROM Department d WHERE d.department_parent.unique_id=?")
				.setParameter(0, parentId)
				.list();
	}
}
